package com.liugui;

/**
 * @ClassName: PriorityDemo
 * @Author: liugui
 * @Date: 2021-05-19 16:12
 **/
public class PriorityDemo {

    public static void main(String[] args) {
        Thread t1 = new Thread(new MyThread3(),"线程A") ;  // 实例化线程对象
        Thread t2 = new Thread(new MyThread3(),"线程B") ;  // 实例化线程对象
        Thread t3 = new Thread(new MyThread3(),"线程C") ;  // 实例化线程对象
        t1.setPriority(Thread.MIN_PRIORITY) ;   // 优先级最低
        t2.setPriority(Thread.MAX_PRIORITY) ;   // 优先级最高
        t3.setPriority(Thread.NORM_PRIORITY) ;  // 优先级最中等
        t1.start();
        t2.start();
        t3.start();
        //并非优先级越高就一定会先执行，哪个线程先执行将由 CPU 的调度决定。
    }
}

